package device;

import base.UsersBaseInterface;
import device.callbacks.VerifyOnce;

import java.nio.channels.SocketChannel;
import java.util.Collection;
import java.util.HashMap;
import java.util.Objects;

public class AdminDevice extends Device{
    public AdminDevice(SocketChannel socketChannel, UsersBaseInterface users) {
        super(socketChannel, users);
    }

    @Override
    public boolean subscribe(Device targetDevice, VerifyOnce verify) {
        super.subscribe(targetDevice);
        return true;
    }

    @Override
    public void update(HashMap<String, String> msgsSet) {
        Collection<String> keySet = msgsSet.keySet();
        for (String key : keySet) {
            String value = keys.get(key);
            String msgValue = msgsSet.get(key);
            if (msgValue != null) {
                if (!msgValue.equals(value)) {
                    keys.put(key, msgValue);
                    updateFlag = true;
                }
            }
        }
    }


    public Boolean comparePassword(String password) {
        String adminPassword = "152637";
        return Objects.equals(password, adminPassword);
    }
}
